Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: omitted $ref parameters #15

Merged
merged 1 commit into from
Dec 16, 2024

Conversation

markandrus
Copy link
Contributor

@markandrus markandrus commented Dec 14, 2024

I noticed there are some cases where parameters using $ref were omitted. This happens due to deleting the in property from the parameter, which then means, if the parameter is shared, it not longer has an in property, and is excluded from subsequent codegen steps. To fix that, I copy param in writeParameter.

Before this fix

const schema = {
  '/foo1': {
    GET: {
      args: T.Optional(
        T.Object({
          query: T.Optional(
            T.Object({
              bar: T.Optional(T.String({ 'x-in': 'query' }))
            })
          )
        })
      ),
      data: T.Any({ 'x-status-code': '201' }),
      error: T.Union([T.Any({ 'x-status-code': 'default' })])
    }
  },
  '/foo2': {
    GET: {
      args: T.Void(),
      data: T.Any({ 'x-status-code': '201' }),
      error: T.Union([T.Any({ 'x-status-code': 'default' })])
    }
  }
}

After this fix

const schema = {
  '/foo1': {
    GET: {
      args: T.Optional(
        T.Object({
          query: T.Optional(
            T.Object({
              bar: T.Optional(T.String({ 'x-in': 'query' }))
            })
          )
        })
      ),
      data: T.Any({ 'x-status-code': '201' }),
      error: T.Union([T.Any({ 'x-status-code': 'default' })])
    }
  },
  '/foo2': {
    GET: {
      args: T.Optional(
        T.Object({
          query: T.Optional(
            T.Object({
              bar: T.Optional(T.String({ 'x-in': 'query' }))
            })
          )
        })
      ),
      data: T.Any({ 'x-status-code': '201' }),
      error: T.Union([T.Any({ 'x-status-code': 'default' })])
    }
  }
}

@markandrus markandrus force-pushed the fix-omitted-ref-parameters branch from c4fa9e1 to f1ba5d6 Compare December 14, 2024 19:21
@tinchoz49 tinchoz49 merged commit 7fddb3e into geut:main Dec 16, 2024
1 check passed
@markandrus markandrus deleted the fix-omitted-ref-parameters branch December 17, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants